/**
 * 
 */
package com.recording.system.sensor;

import java.util.ArrayList;

import com.recording.system.events.RecordingSystemEvent;
import com.recording.system.events.RecordingSystemEventKind;
import com.recording.system.signalsource.SignalSource;

/**
 * @author bpkx1031
 *
 */
public class ManualTransmissionChangeSensor extends AbstractSensor {

	public static final String MANUAL_TRANSMISSION_CHANGED = "Manual transmission changed, new transmission : ";
	/**
	 * @param sourceId
	 */
	public ManualTransmissionChangeSensor(int sourceId) {
		super(sourceId);
	}

	private int transmissionNumber = 0;
	/* (non-Javadoc)
	 * @see com.recording.system.sensor.AbstractSensor#readSignalSource(com.recording.system.signalsource.SignalSource, java.util.ArrayList)
	 */
	@Override
	public void readSignalSource(SignalSource source,
			ArrayList<RecordingSystemEvent> res) {
		int newTransmissionNumber = (int) source.getValue();
		if (transmissionNumber != newTransmissionNumber)
		{
			RecordingSystemEvent event = new RecordingSystemEvent(RecordingSystemEventKind.MANUAL_TRANSMISSION_CHANGE, MANUAL_TRANSMISSION_CHANGED + newTransmissionNumber);
			res.add(event);
			transmissionNumber = newTransmissionNumber;
		}
	}

}
